<template>
	<view>

	</view>
</template>
<script>
	import util from "../../util/textUtil.js"
	import ailPay  from "../../util/ailApi.js"
	export default {
		data() {
			return {
				price: "",
				finish: false,
				tradeId: "",
				code:""
			}
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: "支付"
			});
			this.price = options.price;
			this.tradeId = options.tradeId;
			this.code = options.code;
			this.repay();
		},
		methods: {
			finishPay: function() {
				uni.navigateBack({
					delta: 1
				})
			 },
			    log:function(obj){
			        $("#result").append(obj).append(" ").append("<br />");
			    },
			repay: function(tradeId) {
				
				uni.request({
					url: getApp().globalData.baseUrl + 'order/tranrecord/allinPay',
					method: 'POST',
					data: {
						"tradeId": this.tradeId, // tradeId
						"source": "alipay",
						"type": 3,
						"code": this.code
					},
					success: res => {
					console.log(res);
					if (res.data.code == 0) {
						  ailPay(res.data.data.tradeNO, function(res) {
							/*成功的回调*/
							console.log("支付成功");
						
						}, function(e) {
							uni.showToast({
								title: e,
								icon: 'none'
							});
							console.log("支付失败或取消支付")
						})
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						});
					}
					},
					fail: () => {},
				});
			}
		}
	}
</script>
<style>
</style>
